package com.gzz.orchid.common.core.util.gps;


import com.gzz.orchid.common.core.tuple.Axis;

public class LngLatUtil {


    public static void main(String[] args) {
        String QQ1 = "102.67336149428175,25.029220487222112"; // 大观建材木制品市场
        String AA = "102.679935,25.035044";
        String QQ2 = "102.71218915198133,24.99360614907688"; // 理想小镇
        String BB = "102.718499,24.999847";
        Axis axis = new Axis(AA);
        Axis dest = new Axis(QQ1);
        System.out.println("args = " + String.format("%.2f", axis.distance(new Axis(BB))) + "公里");
        System.out.println("args = " + String.format("%.2f", dest.distance(new Axis(QQ2))) + "公里");
    }

    public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) {

        // 维度

        double lat1 = (Math.PI / 180) * latitude1;

        double lat2 = (Math.PI / 180) * latitude2;

        // 经度

        double lon1 = (Math.PI / 180) * longitude1;

        double lon2 = (Math.PI / 180) * longitude2;

        // 地球半径

        double R = 6371;

        // 两点间距离 km

        double d = Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)) * R;

        return d * 1000;

    }

}